home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 565 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: ts5-024.jaxnet.com!user
  2. From: garyg@jax.jaxnet.com (Gary M. Greenberg)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Is this ok: *pointer++ = value ??
  5. Date: Sat, 06 Jan 1996 22:11:53 -0500
  6. Organization: Southeast Network Services, Inc.
  7. Message-ID: <garyg-0601962211530001@ts5-024.jaxnet.com>
  8. References: <4cklvv$nmm@alcor.usc.edu> <4cm710$ni1@nntpd2.cxo.dec.com>
  9. NNTP-Posting-Host: ts5-024.jaxnet.com
  10.  
  11. In article <4cm710$ni1@nntpd2.cxo.dec.com>, Brian Hibbert
  12. <b_hibbert@csc32.enet.dec.com> wrote:
  13.  
  14. [snip]
  15. > >       int i,p;
  16. > >
  17. > >       for (i=0; i<50; i++) p++ = i;
  18. > >
  19. > This is undefined because it is no clear what the compiler is supposed to 
  20. > do.  Do you increment the value of "p" first then assign the value of 
  21. > "i" to "p".  Or do you assign the value of "i" to "p" then increment 
  22. > "p"?  How you answer that question determines wether "p" ends up with the 
  23. > value of "i" or "i+1".  Exactly what happens on your compiler is 
  24. > undefined and therefor the compiler could do it either way, could flag it 
  25. > as an error, or could decide to put any value it wants in "i" and "p".  
  26.  
  27. Undefined??! It's illegal.
  28. It shouldn't compile because you cannot assign a value
  29. to something which is _not_ an object; that is, "p" is not an lvalue.
  30. Or, have I missed something?
  31.  
  32. Pointer <pun intended> for Abu <originator of this thread> && Brian ;-) :
  33. grab a copy of Ted Jensen's "A Tutorial on Pointers And Arrays in C"
  34. available as
  35.     ftp://oak.oakland.edu/simtel/msdos/c/ptrtut01.zip
  36.  
  37. > Brian Hibbert
  38.  
  39. C'ya,
  40.  
  41. gary /* the Sorcerer's Apprentice */
  42.  
  43. "Why do we have to hide from the police, Daddy?" | Truth:
  44. "Because we use vi, honey. They use emacs."      | This .sig is pirated
  45.